<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php echo $this->Html->charset(); ?>

        <title>

            <?php echo $title_for_layout; ?>
        </title>



        <?php
        echo $this->Html->meta('icon');
        echo $this->Html->script(array('jquery-1.7.2.min', 'jquery-ui-1.8.21.custom.min',
            'bootstrap.min'));
        echo $this->Html->css(array('bootstrap.min', 'jquery-ui-1.8.21.custom'));
        echo $this->fetch('meta');
        echo $this->fetch('css');
        echo $this->fetch('script');
        ?>

        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;

            }

        </style>
        <script>
            $(document).ready(function(){
                $(".test").click(function (e) {
                    $.ajax({ url: '\accounts/selectAccount',
                        data: {twitterAccountName:this.id},
                        type: 'post',
                        success: function(output) {
                            location.reload();
                        }
                    }); 
                });

            });

        </script>
    </head>

    <body>
        <!-- The first two lines of  code define the upper navigation bar. -->
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container-fluid">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </a><!--btn-navbar-->
                    <!-- Include here any links that you don't want appearing in the drop down list-->
                    <a class="brand" href="\tweetar/">Tweetar</a>
                    <div class="nav-collapse">
                        <ul class="nav ">
                            <!-- Include here any other links. Sample below ! -->
                            <li><?php echo $this->Html->link('Home', array('controller' => 'Accounts')); ?></li>
                            <li><?php echo $this->Html->link('Analytics', array('controller' => 'Analytics')); ?></li>
                            <li><?php echo $this->Html->link('Timeline',array('controller'=>'FutureTweets','action'=>'view',$current_account));?></li>
                            <li><?php echo $this->Html->link('Dashboard', array('controller' => 'Posts')); ?></li>
                            <li><?php echo $this->Html->link('Buffer', array('controller' => 'FutureTweets','action'=>'index')); ?></li>
                            <!--<li><a href="/tweetar/posts" id = "dash"><i  class ="icon-home icon-white"></i>Dashboard</a></li>-->
                            <li><?php echo $this->Html->link('DB', array('controller' => 'Accounts', 'action' => 'db')); ?></li>
                            <li><?php echo $this->Html->link('Assign Postions', array('controller' => 'Accounts', 'action' =>'assign_pos')); ?></li>

                        </ul>
                    </div> 
                    <ul class="nav pull-right">
                        <li class="divider-vertical"></li>

                        <?php $array = ClassRegistry::init('accounts_user')->find('all', array('conditions'=>array('permission'=>'moderator')));

                        if(count($array)>0){
                        ?>
                        <li class="dropdown">
                            <a class="dropdown-toggle"
                               data-toggle="dropdown"
                               href="#">
                               <?php if(count($notifications) > 0 ){?>
                               <span class="badge badge-important pull-left"> <?php echo count($notifications); ?></span><?php }?>
                               &nbsp;
                               <i class = ' icon-eye-open'></i>
                                Notifications
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">

                                <?php for ($i = 0; $i < count($notifications); $i++) { ?>
                                    <li ><a href=<?php echo "/tweetar/FutureTweets/pending/"."".$notifications[$i]['future_tweet']['account_id']?>> <img src='<?php echo $acc[$i]['Account']['image']; ?>'  height="22" width="22" />&nbsp;<?php echo ' new tweets need to be approved'; ?></a></li>
                                <?php } ?>
                            </ul>
                        </li>

                       <?php }?>

                        <li class="dropdown">
                            <a class="dropdown-toggle"
                               data-toggle="dropdown"
                               href="#">
                                 <?php if (!empty($currentlySlectedAccount)) { ?>
                                       <?php echo $currentlySlectedAccount['0']['Account']['screen_name']; ?>
                                   <?php } else { ?>
                                    Accounts
                                <?php } ?>
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">
                                <?php if (empty($accountsArrayManager) && empty($accountsArrayModerator) && empty($accountsArrayEditor)) { ?>
                                    <li style="text-align: center">You have no accounts</li>
                                <?php } ?>
                                <?php if (!empty($accountsArrayManager)) { ?>
                                    <li class="divider"></li>
                                    <li style="text-align: center">Managing</li>
                                    <li class="divider"></li>
                                <?php } ?>
                                <?php for ($i = 0; $i < count($accountsArrayManager); $i++) { ?>
                                    <li > <a class="test" id='<?php echo $accountsArrayManager[$i]['Account']['screen_name']; ?>'><img src='<?php echo $accountsArrayManager[$i]['Account']['image']; ?>' /> <?php echo $accountsArrayManager[$i]['Account']['screen_name']; ?></a></li>
                                <?php } ?>
                                <?php if (!empty($accountsArrayModerator)) { ?>
                                    <li class="divider"></li>
                                    <li style="text-align: center">Moderating</li>
                                    <li class="divider"></li>
                                <?php } ?>
                                <?php for ($i = 0; $i < count($accountsArrayModerator); $i++) { ?>
                                    <li > <a class="test" id='<?php echo $accountsArrayModerator[$i]['Account']['screen_name']; ?>'><img src='<?php echo $accountsArrayModerator[$i]['Account']['image']; ?>' /> <?php echo $accountsArrayModerator[$i]['Account']['screen_name']; ?></a></li>
                                <?php } ?>
                                <?php if (!empty($accountsArrayEditor)) { ?>
                                    <li class="divider"></li>
                                    <li style="text-align: center">Editing</li>
                                    <li class="divider"></li>
                                    <?php for ($i = 0; $i < count($accountsArrayEditor); $i++) { ?>
                                        <li > <a class="test" id='<?php echo $accountsArrayEditor[$i]['Account']['screen_name']; ?>'><img src='<?php echo $accountsArrayEditor[$i]['Account']['image']; ?>' /> <?php echo $accountsArrayEditor[$i]['Account']['screen_name']; ?></a></li>
                                    <?php } ?>
                                <?php } ?>
                            </ul>
                        </li>
                        <div class="btn-group pull-right">
                            <a class="btn dropdown-toggle " data-toggle="dropdown" href="#">
                                &nbsp;
                                <i class="icon-user"></i>
                                <?php echo $email ; ?>

                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                
                                <li><?php echo $this->Html->link('Add Twitter Account', array('controller' => 'Accounts', 'action' => 'addTwitterAccount')); ?></li>
                                <li><a href="/tweetar/buffers/setting"> Settings</a></li>
                                <li><a href="/tweetar/users/changePassword">Update Password</a></li>
                                <li class="divider"></li>
                                <li><?php echo $this->Html->link('Logout', array('controller' => 'Users', 'action' => 'logout')); ?></li>
                                <!-- dropdown menu links -->
                            </ul>
                        </div>      
                    </ul>


                </div><!--container-->
            </div><!--.navbar-inner-->
        </div><!--navbar-->
        <div class ="container-fluid2">
            <div class ="row-fluid">
                <div class ="span2">
                    <div class="well">
                        <ul class="nav nav-list">
                            <li class="nav-header">Settings</li>
                            <li  class="active" ><?php echo $this->Html->link('customize  Buffer', array('controller' => 'Buffers', 'action' => 'setting')); ?></li>
                             <li><a href="#">change password</a></li>

                        </ul>
                       
                    </div>

                    <br />
                </div><!--span3-->
                <div class="span10 well">
                        <div id = "Test" class = "Notification" ></div>

                        <?php echo $this->Session->flash(); ?>
                        <?php echo $this->Session->flash('auth'); ?>
                        <?php echo $this->fetch('content'); ?>

                </div><!--span6-->


            </div><!--row-->
        </div>

        <?php echo $this->element('sql_dump'); ?>

    </body>
</html>
